<html>

	<head>
		<meta charset="UTF-8">
		<title>合同列表</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<link rel="stylesheet" href="../../layui/css/layui.css" />
		<link rel="stylesheet" href="../../css/bass.css" />
		<style>
		.layui-form{
			width:35%;
		}
		.layui-input{
			width: 100% !important;
		}
	</style>
	</head>

	<body>
		<div class="body">
			<header class="layui-nav" id="headerTop"></header>
			<div class="left_muen" id="left_menu"></div>
			<div class="content_body">

				<!--标题栏-->
				<p class="content_title">设备管理 &nbsp;&nbsp;>&nbsp;&nbsp;厂商列表&nbsp;&nbsp;>&nbsp;&nbsp;修改厂商</p>
				<!--标题栏-->

				<form class="layui-form mt20">
					<div class="layui-form-item">
						<label class="layui-form-label">厂商简称</label>
						<div class="layui-input-block">
							<input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入序号" class="layui-input w30">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">厂商全称</label>
						<div class="layui-input-block">
							<input type="text" name="allname" lay-verify="required" placeholder="请输入合同编号" autocomplete="off" class="layui-input w30">
						</div>
					</div>
					<div class="layui-form-item">
						<!--<div class="layui-inline">-->
							<label class="layui-form-label">厂商类型</label>
							<div class="layui-input-block">
								<select name="businessType" lay-verify="required" lay-search="">
									<option value="1">供应商</option>
									<option value="2">厂家</option>
								</select>
							</div>
						<!--</div>-->
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">上传周期</label>
						<div class="layui-input-block">
							<input type="text" name="circuitId" lay-verify="required|number" style="display: inline-block" placeholder="请输入上传周期" autocomplete="off" class="layui-input w30">
							<!--<span style="font-size: 16px"> /分钟</span>-->
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">描述</label>
						<div class="layui-input-block">
							<input type="text" name="contractDesc" lay-verify="" placeholder="请输入描述" autocomplete="off" class="layui-input w30">
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<div class="layui-btn" lay-submit="" lay-filter="submitFilter">立即提交</div>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<script src="../../js/common/jquery-1.11.3.min.js"></script>
		<script src="../../layui/layui.js"></script>
		<script src="../../js/common/navList.js"></script>
		<script src="../../js/common/ajax.js"></script>
		<script>
			var href = window.location.href;
			var id = href.split("?")[1].split("&")[2] ? href.split("?")[1].split("&")[2].split("=")[1] : "";
			if(id) {
				//初始化页面值
				$.ajax({
					url: baseUrl + "/manufacturer/getById?id=" + id,
					type: "GET",
					dataType: "json",
					success: function(data) {
						console.log(data);
						$("[name = name]").val(data.maTitle);
						$("[name = allname]").val(data.maAllTitle);
						$("[name = businessType]").val(data.maType);
						$("[name = circuitId]").val(data.uploadCycle);
						$("[name = contractDesc]").val(data.maDesc);
					}
				});
			}
			layui.use(['form', 'layedit'], function() {
				var form = layui.form,
					layer = layui.layer,
					layedit = layui.layedit;
				//监听提交
				form.on('submit(submitFilter)', function(data) {
					console.log(data.field)
					ajaxPost({
						url: 'manufacturer/update',
						data: {
							id: id,
							maTitle: data.field.name,
							maAllTitle: data.field.allname,
							maType: data.field.businessType,
							uploadCycle: data.field.circuitId,
							maDesc: data.field.contractDesc,
						},
						successFull: function(res) {
							console.log(res)
							layer.msg('添加成功', {
								icon: 6
							});
							window.location.href = "./accountsShopList.html?pos=0&childPos=1";
						},
						errCallBack: function(res) {
							layer.msg(res.msg, {
								icon: 6
							});
						}
					})
				});
			});
		</script>
	</body>

</html>